package com.sxpi.zixun.controller.resources;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sxpi.zixun.bo.ResourcesBo;
import com.sxpi.zixun.controller.BaseController;
import com.sxpi.zixun.service.resources.IResourcesService;
import com.sxpi.zixun.vo.ResourcesVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.pug.generator.anno.PugDoc;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 董伟豪
 * @Date: 2022/9/2 19:33
 */
@RestController
@RequiredArgsConstructor
@Slf4j
@PugDoc(name="资源库",tabname="kss_resources")
public class ResourcesController extends BaseController {

    private final IResourcesService resourcesService;

    /**
     * 查询资源库列表信息
     * @param resourcesVo
     * @return
     */
    @PostMapping("/resources/load")
    @PugDoc(name="查询资源库列表信息并分页")
    public IPage<ResourcesBo> findResourcess(@RequestBody ResourcesVo resourcesVo) {
        return resourcesService.findResourcesPage(resourcesVo);
    }

    /**
     * 统计分类下是否存在资源信息
     * @param cid
     * @return
     */
    @PostMapping("/resources/count/{cid}")
    @PugDoc(name="统计分类下是否存在资源信息")
    public int countResourceList(@PathVariable("cid") Long cid) {
        return resourcesService.countResources(cid);
    }
}
